Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account Creation: Fix broken flow after signing up from the WordPress app #21751

Merged
merged 10 commits into from
Oct 15, 2023

Conversation

hassaanelgarem
Copy link
Contributor

@hassaanelgarem hassaanelgarem commented Oct 12, 2023

Fixes #21746

Description

This PR fixes an issue where users signing up on the WordPress app land on the Reader while it should not be accessible.

The PR also introduces logic for synchronizing calls to fetch the remote feature flags, making sure that the latest network call is always respected regardless of when the response comes. This is to avoid the following scenario:

  1. Unauthenticated request to fetch feature flags made (Request A)
  2. User logs in
  3. Authenticated request to fetch feature flags made (Request B)
  4. Response for request B returned and values updated
  5. ❌ Response for request a returned and values overridden

Testing Instructions

  1. Delete both WordPress and Jetpack apps
  2. Install WordPress
  3. Create a new account via email
  4. Background the app, do not close it
  5. Confirm your new account's email on the same device
  6. You should be navigated back to the WordPress app automatically
  7. Tap "Done"
  8. Tap "Not right now"
  9. ✅ Make sure that you land on My Site with the tab bar & Jetpack features hidden

Regression Notes

  1. Potential unintended areas of impact
    Sign up flow on Jetpack

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Tested manually

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Oct 12, 2023

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr21751-67e1e15
Version23.4
Bundle IDorg.wordpress.alpha
Commit67e1e15
App Center BuildWPiOS - One-Offs #7408
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Oct 12, 2023

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr21751-67e1e15
Version23.4
Bundle IDcom.jetpack.alpha
Commit67e1e15
App Center Buildjetpack-installable-builds #6438
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@wargcm wargcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! There was just a minor typo with a function name, but everything works 🎉

WordPress/Classes/System/RootViewCoordinator.swift Outdated Show resolved Hide resolved
@hassaanelgarem hassaanelgarem merged commit cc8bf91 into trunk Oct 15, 2023
@hassaanelgarem hassaanelgarem deleted the fix/21746-wp-sign-up-happy-path branch October 15, 2023 15:57
Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I landed on this PR while checking the editorialized release notes.

Comment on lines +117 to +131
if self?.isCancelled == true {
self?.state = .isFinished
DDLogInfo("🚩 Feature flags update operation canceled")
self?.completion(.failure(OperationError.operationCanceled))
return
}
switch result {
case .success(let flags):
DDLogInfo("🚩 Successfully updated local feature flags: \(flags.dictionaryValue)")
self?.completion(.success(flags.dictionaryValue))
case .failure(let error):
DDLogError("🚩 Unable to update Feature Flag Store: \(error.localizedDescription)")
self?.completion(.failure(error))
}
self?.state = .isFinished
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm reading the code wrong, if self is nil, nothing will happen other than console logs.

Have you considered returning early with guard let self else { return }?

Comment on lines +350 to +358
internal extension RemoteFeatureFlagStore {
func update(using remote: FeatureFlagRemote, waitOn test: XCTestCase) {
let exp = test.expectation(description: "Store finishes update")
update(using: remote) {
exp.fulfill()
}
test.wait(for: [exp], timeout: 1)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting approach. For a moment I got worried because it looked like the test was no longer testing application code, but then I looked at the implementation and realized it called the app code internally.

This has definitely value because it DRYes what would otherwise be a lot of repeated async expectations.

I wonder if the DRY could be pushed even further. Most tests have a similar arrange structure:

        let store = ...
        let flags = ...
        let remote = ...
        store.update(using: remote, waitOn: self)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WordPress: Migration phase incorrect for first time users
4 participants